package com.redoor.iot.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

public class User implements Serializable{
    

	/**
	 * 
	 */
	private static final long serialVersionUID = 7954498708325949163L;

	private Long userId;

	@Length(max=20,message="用户名称长度不能超过20！")
    private String userName;

	@NotEmpty(message="{user.userAccount.notNull}")
    @Length(max=20,message="用户账号长度不能超过20！")
    @Pattern(regexp="^[a-zA-Z0-9]+$",message="{user.userAccount.Pattern}")
    private String userAccount;

	@NotEmpty(message="密码不能为空！")
    private String password;

    private String userDesc;

    private Integer userType;

    @Email(message="邮箱格式错误！")
    private String email;

    private Integer status;

    private String activeCode;

    private Date tokenExptime;

    private Date createTime;

    private Date updateTime;
    
    //角色集合
    private List<Long> roleIds;
    
    public User(){}
    public User(User user){
        this.userName = user.getUserName();
        this.password = user.getPassword();
        this.userId = user.getUserId();
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public String getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(String userAccount) {
        this.userAccount = userAccount == null ? null : userAccount.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public String getUserDesc() {
        return userDesc;
    }

    public void setUserDesc(String userDesc) {
        this.userDesc = userDesc == null ? null : userDesc.trim();
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getActiveCode() {
        return activeCode;
    }

    public void setActiveCode(String activeCode) {
        this.activeCode = activeCode == null ? null : activeCode.trim();
    }

    public Date getTokenExptime() {
        return tokenExptime;
    }

    public void setTokenExptime(Date tokenExptime) {
        this.tokenExptime = tokenExptime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

	public List<Long> getRoleIds() {
		return roleIds;
	}

	public void setRoleIds(List<Long> roleIds) {
		this.roleIds = roleIds;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("User [userId=");
		builder.append(userId);
		builder.append(", userName=");
		builder.append(userName);
		builder.append(", userAccount=");
		builder.append(userAccount);
		builder.append(", password=");
		builder.append(password);
		builder.append(", userDesc=");
		builder.append(userDesc);
		builder.append(", userType=");
		builder.append(userType);
		builder.append(", email=");
		builder.append(email);
		builder.append(", status=");
		builder.append(status);
		builder.append(", activeCode=");
		builder.append(activeCode);
		builder.append(", tokenExptime=");
		builder.append(tokenExptime);
		builder.append(", createTime=");
		builder.append(createTime);
		builder.append(", updateTime=");
		builder.append(updateTime);
		builder.append(", roleIds=");
		builder.append(roleIds);
		builder.append("]");
		return builder.toString();
	}
    
    
}